#ifndef UTILS_H_
#define UTILS_H_

#include <map>
#include <set>

template <class K, class V>
class MapValuesIterator {
public:
    MapValuesIterator(std :: map<K, V>* the_map) {
        begin = the_map -> begin();
        end = the_map -> end();
    }
    
    bool hasNext() {
        return begin != end;
    }
    V next() {
        V value = begin -> second;
        begin++;
        return value;
    }
    
private:
    typedef typename std :: map<K, V> :: iterator MapIterator;
    MapIterator begin, end;
};

template <class K>
class SetIterator {
public:
    SetIterator(std :: set<K>* the_set) {
        begin = the_set -> begin();
        end = the_set -> end();
    }
    
    bool hasNext() {
        return begin != end;
    }
    K next() {
        K value = *begin;
        begin++;
        return value;
    }
    
private:
    typedef typename std :: set<K> :: iterator SetIt;
    SetIt begin, end;
};

#endif
